library(tidyverse)

load('data/hr_sims.RData')

p1 = out2 %>% pivot_longer(!dropprob) %>%
  ggplot(aes(x = dropprob)) + ylim(c(0,1)) +
  geom_smooth(aes(y=value, linetype = name), lwd=1.5, col="black") + 
  xlab("Prop. Observed Ideal Points") +
  ylab("") + 
  ggtitle("117th Congress Cosponsorship") +
  theme_bw() + 
  geom_vline(xintercept = 0.2, linetype = "dotted", lwd=2) +
  #theme(legend.position = 'none') +
  scale_linetype_discrete(name = "Statistic",
                       labels = c("Correlation",
                                  "MAD",
                                  "Same Sign"))

load('data/simple_sims.RData')

p2 = out2 %>% pivot_longer(!dropprob) %>%
  ggplot(aes(x = dropprob)) + ylim(c(0,1)) +
  geom_smooth(aes(y=value, linetype = name), lwd=1.5, col="black") + 
  xlab("Prop. Observed Ideal Points") +
  ylab("") + 
  ggtitle("Simulated Data") +
  theme_bw() +
  geom_vline(xintercept = 0.2, linetype = "dotted", lwd=2) +
  scale_linetype_discrete(name = "Statistic",
                      labels = c("Correlation",
                                 "MAD",
                                 "Same Sign"))

library(cowplot)


tmp = plot_grid(p1, p2, nrow=2)
tmp2 = paste0(here::here(), "/figures/app_fig4.pdf")
save_plot(tmp2, tmp)
